import time

import pytest
import common.yaml_utils as yamlUtils
from selenium import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver
from model.high_def_cloud_buy_page import HighDefCloudBuyPage


@pytest.fixture(name="driver", scope="module")
def init():
    driver = webdriver.Chrome(executable_path="./chromedriver_87.exe")  # 创建Chrome对象.
    driver.maximize_window()
    return driver


"""
    定义通用的场景设计
"""


@pytest.fixture(scope="module")
def Login(driver):
    driver.get("http://test.kkclouds.com/passport/cloudlogin.html")
    username = driver.find_element_by_xpath("//*[@id=\"username\"]")
    password = driver.find_element_by_xpath("//*[@id=\"password\"]")
    loginButton = driver.find_element_by_xpath("//*[@id=\"login\"]")
    username.send_keys("kkwlcs")
    password.send_keys("a123456")
    loginButton.click()
    time.sleep(5)
    yield
    print("after")
